package com.objectproject.main.controller;

import java.util.Locale;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.objectproject.main.dao.MyLocaleDAOImpl;
import com.objectproject.main.dao.MyObjectDAOImpl;
import com.objectproject.main.dao.MyPrimitiveDAOImpl;
import com.objectproject.main.exception.PropertyRefineException;
import com.objectproject.main.model.MyPropertiesCommandModel;
import com.objectproject.main.service.subsystem.MyLocaleResolver;

/**
 * Handles requests for the application home page.
 */
@Controller
public class PropertyController {
	
	@Autowired
	MyObjectDAOImpl myObjectDAOImpl;
	
	@Autowired
	MyPrimitiveDAOImpl myPrimitiveDAOImpl;
	
	@Autowired
	MyLocaleDAOImpl myLocaleDAOImpl;
	
	@Autowired
	MyLocaleResolver myLocaleResolver;
	
	
	private static final Logger logger = LoggerFactory.getLogger(PropertyController.class);
	
	@RequestMapping(value = "/addProperteis", method = RequestMethod.POST)
	public String home(@ModelAttribute MyPropertiesCommandModel  myPropertiesCommandModel, HttpServletRequest request, HttpServletResponse response, Locale locale, Model model) throws PropertyRefineException {
		logger.info("Welcome home! The client locale is {}.", locale);
		
		myPropertiesCommandModel.refine();
		
		System.out.println(myPropertiesCommandModel);
		
		return "index";
	}
	
	
	
}

